home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Fade Me 1.1 / source / sdf code ƒ / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  1.8 KB  |  92 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        init.c
  4.  
  5. Purpose:    This module handles INIT initialization and installation.
  6.             
  7.  
  8. Shutdown Fade -=- fade the screen to black on shutdown
  9. Copyright (C) 1993 Mark Pilgrim
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "init.h"
  29. #include "fade.h"
  30. #include "environment.h"
  31. #include "notify.h"
  32. #include "gamma.h"
  33. #include "ShutDown.h"
  34.  
  35. Handle            initHandle;            /* handle to main init code */
  36. THz                saveZone;
  37.  
  38. void __GetA4(void)
  39. {
  40.     asm {
  41.         bsr.s    @1
  42.         dc.l    0            ;  store A4 here
  43. @1        move.l    (sp)+,a1
  44.     }
  45. }
  46.  
  47. /* this be the init startup install routine thing */
  48. void main(void)
  49. {
  50.     OSErr            isHuman;
  51.     int                resultCode;
  52.     
  53.     RememberA0();
  54.     SetUpA4();
  55.     
  56.     PrepareEnvironment();
  57.     if (IsGammaAvailable())
  58.     {
  59.         asm
  60.         {
  61.             movea.l            a4, a0
  62.             RecoverHandle
  63.             move.l            a0, initHandle
  64.         }
  65.         if(isHuman = MemError())
  66.         {
  67.             StartupError();
  68.         }
  69.         else
  70.         {
  71.             HLock(initHandle);
  72.             HNoPurge(initHandle);
  73.             
  74.             DoSetup();
  75.             StartupGood();
  76.         }
  77.     }
  78.     else
  79.     {
  80.         StartupError();
  81.     }
  82.     
  83.     RestoreEnvironment();
  84.     
  85.     RestoreA4();
  86. }
  87.  
  88. void DoSetup(void)
  89. {
  90.     ShutDwnInstall((ProcPtr)&DoTheFadeThing, sdOnPowerOff);
  91. }
  92.